package com.mapfinal.server;

import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.lambkit.LambkitApplication;
import com.lambkit.LambkitApplicationContext;
import com.lambkit.module.LambkitModule;
import com.lambkit.web.cros.CrossInterceptor;
import com.lambkit.web.handler.MyFakeStaticHandler;
import com.mapfinal.server.api.ApiModule;
import com.mapfinal.server.auth.AuthModule;
import com.mapfinal.server.common.CommonModule;
import com.mapfinal.server.layer.ServerLayerModule;
import com.mapfinal.server.mgrdb.MapfinalMgrdbModule;

/**
 * mapfinal server start class
 * 
 * @author yangyong
 *
 */
public class MapfinalServerApplication extends LambkitApplicationContext {

	@Override
	public void configModule(LambkitModule module) {
		// TODO Auto-generated method stub
		super.configModule(module);
		// Mgrdb
		module.addModule(new MapfinalMgrdbModule());
		// 全局配置
		module.addModule(new MapfinalServerModule());
		// API
		module.addModule(new ApiModule());
		// 通用设置
		module.addModule(new CommonModule());
		// 图层\数据源\工作空间
		module.addModule(new ServerLayerModule());
		// 用户权限
		module.addModule(new AuthModule());
	}
	
	@Override
	public void configInterceptor(Interceptors interceptors) {
		// TODO Auto-generated method stub
		super.configInterceptor(interceptors);
		interceptors.add(new CrossInterceptor());
	}
	
	@Override
	public void configHandler(Handlers handlers) {
		// TODO Auto-generated method stub
		super.configHandler(handlers);
		handlers.add(new MyFakeStaticHandler());
	}
	
	public static void main(String[] args) {
		LambkitApplication.run(MapfinalServerApplication.class, args);
	}
}
